import Vue from "vue"
import vuex from "vuex"
import {getItem , setItem,removeItem} from "@/utils/localStorage.js"
Vue.use(vuex);
const yxToken = "YANXUANTOKEN"
const userInfo="USERINFOMESSAGE"
const store = new vuex.Store({
    state:{
        token:getItem(yxToken),
        userInfo:{}
    },
    mutations:{
        setUserToken(state,data){
            state.token = data;
            setItem(yxToken,state.token);
        },
        // 清除token
        removeUserToken(state){
            state.token = null;
            removeItem(yxToken)
        },
        // 储存用户信息;
        setUserInfo(state,obj){
            state.userInfo = obj;
            setItem(userInfo , obj)
        },
        

    },
    // actions:{
    //     setUserInfoToken(context,data){
    //         context.commit("setUserToken",data)
    //     }
    // },
    getters:{},
    modules:{}
});
export default store;

